<? var_dump($setpm);?>
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="">
    <meta name="keyword" content="">

    <title>流程设定</title>

    <!-- Bootstrap core CSS -->
    <link href="__PUBLIC__/css/bootstrap.min.css" rel="stylesheet">
    <link href="__PUBLIC__/dist/css/AdminLTE.min.css" rel="stylesheet" type="text/css">
    
    <link href="__PUBLIC__/css/bootstrap-reset.css" rel="stylesheet">
    <!--external css-->
    <link href="__PUBLIC__/assets/font-awesome/css/font-awesome.css" rel="stylesheet" />
    <!-- Custom styles for this template -->
    <link href="__PUBLIC__/css/style.css" rel="stylesheet">
    <link href="__PUBLIC__/css/style-responsive.css" rel="stylesheet" />
    <!-- new styles-->
      <link href="__PUBLIC__/css/xxxstyle.css" rel="stylesheet" />

      <!-- HTML5 shim and Respond.js IE8 support of HTML5 tooltipss and media queries -->
    <!--[if lt IE 9]>
      <script src="__PUBLIC__/js/html5shiv.js"></script>
      <script src="__PUBLIC__/js/respond.min.js"></script>
    <![endif]-->
  </head>

  <body>

  <section id="container" class="">
      <!--main content start-->
      <section id="main-content">
          <section class="wrapper site-min-height">
              <!-- page start-->
              <section class="panel pageRangeA">
                  <div class="panel-heading">
                      <i class="glyphicon glyphicon-transfer" style="top:3px;"></i>流程设定
                  </div>
                  <div class="panel-body">
                     <!--  <div class="box-header">
                          <nav class="navbar navbar-default">
                              <div class="collapse navbar-collapse">
                                  <div class="navbar-form form-inline">
                                      <div class="form-group pull-right">
                                          <button data-toggle="modal" class="btn btn-primary" href="#creatProcess"><i class="icon-plus"></i>创建新流程</button>
                                      </div>
                                  </div>
                              </div>
                          </nav>
                      </div> -->
                      <div>
                          <form method="post" target="_blank">
                              <div class="table-responsive">
                                  <table id="list-table" class="table table-bordered table-striped dataTable">
                                      <thead>
                                      <tr role="row">
                                          <th class="text-center">流程名称</th>
                                          <th class="text-center">相关设置</th>
                                      </tr>
                                      </thead>
                                      <tbody>
                                      <?php if(empty($data)) {?>  
	                      				 <tr><td style="text-align: center;" colspan="5">查询不到相关数据</td></tr>
	                				 <?php }?>  
                                        <foreach name="data" item="v" key="k">
                                        <tr role="row" align="center">
                                            <td class="paddingB">{$v.name}</td>
                                            <td class="tdA">
                                                <a class="btn btn-success btn-sm" href="{:U('System/approval',array('id'=>$v['id'],'type'=>$v['type']))}"><i class="icon-paste"></i>审批人<if condition="$v['launch'] neq ''">(已设置)</if></a>
                                                <if condition="$v['type'] neq 2">
                                                <button data-toggle="modal" class="btn btn-primary btn-sm" href="#copyer" onclick=setpm("{$v.id}")><i class="icon-copy"></i>抄送人<if condition="$v['copy'] neq ''">(已设置)</if></button>
                                            	</if>
                                            </td>
                                        </tr>
                                        </foreach>
                                         <tr role="row" align="center">
                                         <td class="paddingB">产品库</td>
                                          <td class="tdA">
                                              <a class="btn btn-success btn-sm" href="{:U('System/approval',array('id'=>all,'type'=>2))}"><i class="icon-paste"></i>审批人<if condition="$library eq 2">(已设置)</if></a>
                                          </td>
                                        </tr>
                                      </tbody>
                                  </table>
                              </div>
                          </form>
                      </div>
                  </div>
              </section>
              <!-- page end-->
          </section>
      </section>
      <!--main content end-->
      <!-- Modal 创建新流程 -->
      <div class="modal fade" id="creatProcess" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
          <div class="modal-dialog">
              <div class="modal-content">
                  <div class="modal-header">
                      <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                      <h4 class="modal-title">创建新流程</h4>
                  </div>
                  <div class="modal-body">
                      <div class="form-group">
                          <label class="col-sm-3 control-label">流程名称</label>
                          <div class="col-sm-9">
                              <input type="text" class="form-control" value="" name="process">
                          </div>
                      </div>
                  </div>
                  <div class="modal-footer">
                      <button data-dismiss="modal" class="btn btn-default" type="button">取消</button>
                      <button class="btn btn-submit" type="button" onclick="add_process()">添加</button>
                  </div>
              </div>
          </div>
      </div>
      <!-- modal -->
      <!-- Modal 抄送人 -->
      <div class="modal fade" id="copyer" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
          
      </div>
      <!-- modal -->
  </section>

    <!-- js placed at the end of the document so the pages load faster -->
    <script src="__PUBLIC__/js/jquery.js"></script>
    <script src="__PUBLIC__/js/jquery-1.8.3.min.js"></script>
    <script src="__PUBLIC__/js/bootstrap.min.js"></script>
    <script class="include" type="text/javascript" src="__PUBLIC__/js/jquery.dcjqaccordion.2.7.js"></script>
    <script src="__PUBLIC__/js/jquery.scrollTo.min.js"></script>
    <script src="__PUBLIC__/js/jquery.nicescroll.js" type="text/javascript"></script>
    <script src="__PUBLIC__/js/jquery.customSelect.min.js" ></script>

    <!--common script for all pages-->
    <script src="__PUBLIC__/js/common-scripts.js"></script>
    <script type="text/javascript" src="__PUBLIC__/js/layer/layer.js"></script>
    <!--new script for this page only-->

  <script>
      $(function(){
          //参数{input类名，选择类型(单选or多选)}
          $(".rdolist").labelauty("rdolist", "rdo");
          $(".chklist").labelauty("chklist", "check");
      });
      
      //添加编制名称
      function add_process(){
      	  var name = $("input[name='process']").val();
      	  if(name==''){
      		  layer.msg('名称不能为空',{icon:2});
      	  }
   		   $.ajax({
    	          type : "POST",
    	          url:'__URL__/definition',
    	          data : {name:name},
    	          dataType : 'json',
    	          success: function(res){
    	        	  if(res.status==0){
    						layer.alert(res.info, {icon: 2});
    						return;
    				  }
    	        	  if(!res.errNo){
   		 				 layer.msg(res.msg,{icon:1});
   		 				 setTimeout("location.reload()",2000);
   			          }else{
   			        	 layer.msg(res.msg,{icon:2});
   			          }
    	          }
    	     });
        }
      
      //ajax设置抄送
      function setpm(o){
    	  $.ajax({
		 		type : 'post',
		 		url : '__URL__/ajaxdefinition',
		 		data : {id:o},
		 		//dataType : 'json',
		 		success : function(res){
		 			if(res.status==0){
						layer.alert(res.info, {icon: 2});
						return;
					 }
		 			 $("#copyer").html('');
                     $("#copyer").append(res);
                     $("#copyer").modal('show');
		 		}
		     })
      }
      //保存设置人员
      function savecopy(aid){
    	  var engs = $("input[name*='copy']");
    	  if(engs.is(":checked")){
              var eng = [];
              for(var k in engs){
                  if(engs[k].checked)
                      eng.push(engs[k].value);
              }
          }
    	 if(eng==undefined){
    		 layer.msg('请勾选抄送人员',{icon:2});
   		     return;
    	 }
   	  $.ajax({
	 		type : 'post',
	 		url : '__URL__/savecopy',
	 		data : {copy:eng,id:aid},
	 		dataType : 'json',
	 		success : function(res){
	 			 if(res.status==0){
						layer.alert(res.info, {icon: 2});
						return;
					 }
	 			 if(!res.errNo){
	 				 $("#copyer").modal('hide');
	 				 layer.msg(res.msg,{icon:1});
	 				 setTimeout("location.reload()",2000);
		          }else{
		        	 layer.msg(res.msg,{icon:2});
		          }
	 		}
	     })
      }
  </script>
  </body>
</html>
